Skip to content

Resolve Bug : #1389 , Fix ConditionalPickDeep incorrectly recursing into unions with null/primitive members #1409

Open
hksinha01 wants to merge 1 commit into
sindresorhus:mainfrom
hksinha01:fix-conditional-pick-deep-enum-paths
Open

Resolve Bug : #1389 , Fix ConditionalPickDeep incorrectly recursing into unions with null/primitive members #1409
hksinha01 wants to merge 1 commit into
sindresorhus:mainfrom
hksinha01:fix-conditional-pick-deep-enum-paths

Conversation

@hksinha01

Copy link
Copy Markdown

Bug

ConditionalPickDeep was incorrectly including keys whose value types are non-object unions (for example string | null) when the Condition is an enum.

This PR fixes the issue in two ways:

  1. Makes the condition check non-distributive using tuple wrapping: [Type] extends [Condition].
  2. Prevents recursion into non-object unions by using: IsPlainObject<NonNullable<Type[Key]>> extends true

Additional tests were added to cover:

  • Enum selection edge case
  • Union types that must not recurse
  • Nested enum cases
  • Verification using Paths<>

@som-sm

som-sm commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Refer #1389 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants